import type { DataTableProps } from "naive-ui";
import { NImage } from "naive-ui";
import { h } from "vue";
import { SHOP_GOODS_CATE_STATUS_COLOR_MAP, SHOP_GOODS_CATE_STATUS_MAP } from '@/const/shop.goods.cate'
import { ORDER_STATUS_COLOR_MAP, ORDER_STATUS_MAP } from '@/const/order'

export const goodsCateColumns: DataTableProps["columns"] = [
	{
		title: '封面',
		key: 'headImg',
		width: 100,
		render: item => h(NImage, {
			src: item.headImg,
			height: 40,
			width: 80,
			objectFit: 'contain',
		})
	},
	{
		title: '名称',
		key: 'name',
		width: 100,
	},
	{
		title: '描述',
		key: 'desc',
		width: 200,
		ellipsis: {
			tooltip: {
				width: 300
			}
		}
	},
	{
		title: '二级分类',
		key: 'categoryList',
		width: 180,
		ellipsis: true,
		render: item => item.categoryList?.map((i: any) => i.name).join(', ')
	},
	{
		title: '状态',
		key: 'status',
		width: 70,
		render(item: any) {
			return h('div', {
				style: {
					color: `var(${SHOP_GOODS_CATE_STATUS_COLOR_MAP[item.status]})`,
				}
			}, [SHOP_GOODS_CATE_STATUS_MAP[item.status]])
		}
	},
]
